<template>
    <div>
        <h3>{{subCount}}</h3>

        <!-- TODO: 执行actions中的方法 -->
        <p>
            <button @click="addnum">增加</button>
        </p>
        <p>
            <button @click="reducesubCount">减少</button>
        </p>

    </div>
</template>

<script>
  import store from '@/store/store'
  import {mapState, mapActions} from 'vuex'
  export default {
    data: () => {
      return {}
    },
    store,
    computed: {
      ...mapState(['subCount'])
    },
    methods: {
      ...mapActions(['addsubCount', 'reducesubCount']),
      addnum() {
        this.addsubCount()
      }
    }
  }
</script>

<style scoped>
</style>